import java.util.Dictionary;
import java.util.HashMap;
import java.util.Scanner;


public class changeElement {
    static int inf = 100001;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()) {
            int n = in.nextInt();
            int []nums = new int[n];   //i->num
            char []colors = new char[n];      //i->char
            for(int i=0;i<n;i++) {
                int num = in.nextInt();
                nums[i] = num;
            }
            String s = in.next();
            for(int i=0;i<n;i++) {
                char c = s.charAt(i);
                colors[i] = c;
            }
            int ans = 0;
            for(int i=0;i<n-1;i++) {
                if(nums[i] == i+1)  continue;
                else if(colors[i] == 'R' && colors[i+1] == 'R') {
                    ans++;
                    int temp = nums[i];
                    nums[i] = nums[i+1];
                    nums[i+1] = temp;
                }
                else{
                    ans = inf;
                    break;
                }
            }
            if(ans == inf)   System.out.println(-1);
            else System.out.println(ans);
        }


    }
}
